import { Property, StandardDataSource, Surrounding } from 'pont-engine'
export default function transform(dataSource: StandardDataSource): StandardDataSource {
	dataSource.baseClasses = dataSource.baseClasses.map((baseClasse) => {
		baseClasse.properties = baseClasse.properties.map((propertie) => {
			if (propertie.dataType.typeName === 'object') {
				propertie.dataType.typeName = 'ObjectMap'
			}
			return propertie
		})
		return baseClasse
	})
	dataSource.mods = dataSource.mods.map((mod) => {
		const parts = mod.name.split('/')
		// 大写每个部分的首字母，除了第一个部分
		const mergedParts = parts.map((part, index) => (index === 0 ? part : part.charAt(0).toUpperCase() + part.slice(1)))
		mod.name = mergedParts.join('')
		mod.interfaces = mod.interfaces.map((res) => {
			let data: Property | undefined
			const parameters = res.parameters.filter((item) => {
				// const ok = item.name !== 'asc' && item.name !== 'column'
				if (item.name === 'asc') {
					data = item
				}
				return item.name !== 'column'
			})
			if (parameters.length !== res.parameters.length) {
				if (data) {
					data.dataType.typeName = `Array<{
						asc: boolean,
						column: string
					  }>`
					data.name = 'orders'
					res.parameters = parameters
				}
			}
			return res
		})

		return mod
	})

	return dataSource
}
